﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DACU.Tools;
using DACU.VkontakteApi.Enums;

namespace DACU.VkontakteApi
{
	class URLTemplates
	{
		public const string LoginUrl = "http://vkontakte.ru/login.php?app={0}&layout=popup&type=browser&settings={1}";
		public const string LoginSuccess = "http://vkontakte.ru/api/login_success.html";
		public const string LoginFailed = "http://vkontakte.ru/api/login_failure.html";
		public const string LongPollServer = "http://{0}?act=a_check&key={1}&ts={2}&wait=25";

		public const string ApiUrl =
			"http://api.vkontakte.ru/api.php?api_id={0}" +//1854119
			"{1}" +//&fields=photo,sex
			"&format={2}" +//JSON
			"&method={3}" +//getProfiles
			"&sid={4}" +//25094e01b4fa6824a6d84a65b5b3a09998e17d18d91ba7d9059689da
			"&sig={5}" +//4a5bf45c9fe5c66d3afa73d8520fe46a
			"{6}" +//&uids=100172
			"&v={7}";//3.0

		public static string GetLoginUrl(string applicationId,VKPermissions permissions)
		{
			return LoginUrl.FormatStr(applicationId, (int) permissions);
		}

		public static string GetApiUrl(string applicationId,string fieldsName,VKResponseFormats format,string method,string sessionId,string signature,string param,string apiVersion)
		{
			return ApiUrl.FormatStr(
				applicationId,
				String.IsNullOrWhiteSpace(fieldsName)?"":"&fields="+fieldsName,
				format.ToString(),
				method,
				sessionId,
				signature,
				String.IsNullOrWhiteSpace(param)?"":"&"+param,
				apiVersion
				);
		}
	}
}
